package net.chenlin.dp.base.service.impl;

import net.chenlin.dp.base.entity.ProjectEntity;
import net.chenlin.dp.base.manager.ProjectManager;
import net.chenlin.dp.base.service.ProjectService;
import net.chenlin.dp.base.service.ProjectService;
import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.Query;
import net.chenlin.dp.common.entity.R;
import net.chenlin.dp.common.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 项目管理
 *
 * @author ZhouChenglin
 * @email yczclcn@163.com
 * @url www.chenlintech.com
 * @date 2018年2月02日 下午4:38:50
 */
@Service("projectService")
public class ProjectServiceImpl implements ProjectService {

	@Autowired
	private ProjectManager projectManager;

	@Override
	public Page<ProjectEntity> listDpProject(Map<String, Object> params) {
		Query query = new Query(params);
		Page<ProjectEntity> page = new Page<>(query);
		projectManager.listDpProject(page, query);
		return page;
	}

	@Override
	public R saveDpProject(ProjectEntity role) {
		int count = projectManager.saveDpProject(role);
		return CommonUtils.msg(count);
	}

	@Override
	public R getDpProjectById(Long id) {
		ProjectEntity dpProject = projectManager.getDpProjectById(id);
		return CommonUtils.msg(dpProject);
	}

	@Override
	public R updateDpProject(ProjectEntity dpProject) {
		int count = projectManager.updateDpProject(dpProject);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(Long[] id) {
		int count = projectManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
